package com.example.fragment;

import com.benchi.ncar.R;
import com.example.tools.Constants;
import com.example.tools.IsNetWork;
import com.lidroid.xutils.ViewUtils;
import android.os.Bundle;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.BounceInterpolator;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;

public class HomeFragment extends BaseFragment {
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		if (mRootView == null) {
			mRootView = inflater.inflate(R.layout.home, container, false);
			initViews();
			super.url = Constants.HOME_URL;
			super.showWaittingDialog();
		}
		initData(Constants.HOME_URL);
		ViewGroup parent = (ViewGroup) mRootView.getParent();
		if (parent != null) {
			parent.removeView(mRootView);
		}
		return mRootView;
	}

	// Web视图
	@Override
	protected void webDispose(WebView view, String url) {
		if (!isTelOrQQ(url)) {
			if (!IsNetWork.isNetworkAvalible(getActivity())) {
				mAbPullListView.setVisibility(View.VISIBLE);
				webview.setVisibility(View.GONE);
				try {
					mAbPullListView.stopRefresh();
				} catch (Exception e) {
				}
			} else {
				Bundle bundle = new Bundle();
				bundle.putString("url", url);
				Message message = new Message();
				message.what = 1;
				message.setData(bundle);
				IMainActivity.handle.handleMessage(message);
			}
		}
	}
}
